<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('易货订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>换入用户：</label>
                                <input type="text" name="userInName"/>
                            </li>
                            <li>
                                <label>换出用户：</label>
                                <input type="text" name="userOutName"/>
                            </li>
                            <li>
                                <label>订单编号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <label style="width: 140px;">换入产品物流号：</label>
                                <input type="text" name="changeIntrackno"/>
                            </li>
                            <li>
                                <label style="width: 140px;">换出产品物流号：</label>
                                <input type="text" name="changeOuttrackno"/>
                            </li>
                            <li>
                                <label style="width: 140px;">换出保证金状态：</label>
                                <select name="changeOutstatus">
                                    <option value="">所有</option>
                                    <option value="0">未缴纳</option>
                                    <option value="1">已缴纳</option>
                                    <option value="-1">已退回</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 140px;">换入保证金状态：</label>
                                <select name="changeInstatus">
                                    <option value="">所有</option>
                                    <option value="0">未缴纳</option>
                                    <option value="1">已缴纳</option>
                                    <option value="-1">已退回</option>
                                </select>
                            </li>
                            <!--<li>
                                <label>换入订单保证金A：</label>
                                <input type="text" name="securityInmoney"/>
                            </li>
                            <li>
                                <label>换出订单保证金B：</label>
                                <input type="text" name="securityOutmoney"/>
                            </li>-->
                            <li>
                                <label style="width: 120px;">换入订单状态：</label>
                                <select name="orderInstatus">
                                    <option value="">所有</option>
                                    <option value="0">待回复</option>
                                    <option value="1">待确认</option>
                                    <option value="2">待发货</option>
                                    <option value="3">待收货</option>
                                    <option value="4">已完成</option>
                                    <option value="5">关闭</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">换出订单状态：</label>
                                <select name="orderOutstatus">
                                    <option value="">所有</option>
                                    <option value="0">待回复</option>
                                    <option value="1">待确认</option>
                                    <option value="2">待发货</option>
                                    <option value="3">待收货</option>
                                    <option value="4">已完成</option>
                                    <option value="5">关闭</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>生成时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <!--<li>
                                <label>收货地址 B：</label>
                                <input type="text" name="orderInaddress"/>
                            </li>
                            <li>
                                <label>收货地址 B：</label>
                                <input type="text" name="orderOutaddress"/>
                            </li>-->
                            <!--<li>
                                <label>换入手机号 A：</label>
                                <input type="text" name="orderInphone"/>
                            </li>
                            <li>
                                <label>换出手机号 B：</label>
                                <input type="text" name="orderOutphone"/>
                            </li>
                            <li>
                                <label>换入收货人 A：</label>
                                <input type="text" name="orderInname"/>
                            </li>
                            <li>
                                <label>换出收货人 B：</label>
                                <input type="text" name="orderOutname"/>
                            </li>
                            <li>
                                <label>换出物流公司编码B：</label>
                                <input type="text" name="changeOuttracknamecode"/>
                            </li>-->

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jjyh:order:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jjyh:order:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jjyh:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jjyh:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jjyh:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jjyh:order:remove')}]];
        var prefix = ctx + "jjyh/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                detailView: true,
                onExpandRow : function(index, row, $detail) {
                    initChildTable(index, row, $detail);
                },
                modalName: "易货订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'userInName',
                    title: '换入用户'
                },
                {
                    field: 'userOutName',
                    title: '换出用户'
                },
                {
                    field: 'orderNo',
                    title: '订单编号'
                },
                {
                    field: 'changeIntrackno',
                    title: '换入产品物流单号'
                },
                {
                    field: 'changeOuttrackno',
                    title: '换出产品物流单号'
                },
               /* {
                    field: 'changeIntrackname',
                    title: '换入物流公司名称'
                },
                {
                    field: 'changeIntracknamecode',
                    title: '换入物流公司编码'
                },*/
                    {
                        field: 'changeInstatusName',
                        title: '换入保证金状态'
                    },
                {
                    field: 'changeOutstatusName',
                    title: '换出保证金状态'
                },
                {
                    field: 'securityInmoney',
                    title: '换入订单保证金'
                },
                {
                    field: 'securityOutmoney',
                    title: '换出订单保证金'
                },
                {
                    field: 'instatusName',
                    title: '换入订单状态'
                },
                {
                    field: 'outstatusName',
                    title: '换出订单状态'
                },
                {
                    field: 'createTime',
                    title: '生成时间'
                },
               /* {
                    field: 'orderInaddress',
                    title: '换入收货地址'
                },
                {
                    field: 'orderOutaddress',
                    title: '换出收货地址'
                },
                {
                    field: 'orderInphone',
                    title: '换入手机号'
                },
                {
                    field: 'orderOutphone',
                    title: '换出手机号'
                },
                {
                    field: 'orderInname',
                    title: '换入收货人'
                },
                {
                    field: 'orderOutname',
                    title: '换出收货人'
                },
                {
                    field: 'changeOuttracknamecode',
                    title: '换出物流公司编码'
                },*/

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewOrder(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                    /*    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        initChildTable = function(index, row, $detail) {
            var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefix + "/listChild",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单商品表",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams : {
                    orderId: row.id
                },
                columns: [{
                    checkbox: true
                },

                    {
                        field: 'goodsTitle',
                        title: '商品'
                    },
                    {
                        field: 'price',
                        title: '价格'
                    },
                    {
                        field: 'num',
                        title: '数量'
                    },
                    {
                        field: 'type',
                        title: '类型'
                    },
                    {
                        field: 'userName',
                        title: '商品归属人'
                    },{
                        field: 'createTime',
                        title: '生成时间'
                    },]
            });

        };

        function viewOrder(id) {
            debugger;
            //$.modal.openNoBtn("查看活动",ctx+"lm/activity/view/"+id);
            var title="查看订单";
            var url=ctx+"jjyh/order/viewOrder/"+id;
            var width;
            var height;
            var callback;
            //如果是移动端，就使用自适应大小弹窗
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            if ($.common.isEmpty(title)) {
                title = false;
            }
            if ($.common.isEmpty(url)) {
                url = "/404.html";
            }
            if ($.common.isEmpty(width)) {
                width = 800;
            }
            if ($.common.isEmpty(height)) {
                height = ($(window).height() - 50);
            }
            if ($.common.isEmpty(callback)) {
                callback = function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            }
            var index= layer.open({
                type: 2,
                area: [width + 'px', height + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: title,
                content: url,
                // 弹层外区域关闭
                shadeClose: true,
                yes: callback,
                cancel: function(index) {
                    return true;
                }
            });
            layer.full(index);
        }

    </script>
</body>
</html>